import request from "@/apps/admin/units/request"
import {HttpResultData, HttpResultPaging, HttpResult} from "@/types/project";

/**
 * 广告操作相关权限
 */
export const POWER: any = {
    LIST: 'data.banner.list',
    CREATED: 'data.banner.created',
    UPDATED: 'data.banner.updated',
    DELETE: 'data.banner.delete'
}

/**
 * 获取广告分类
 */
export const getClassifyDataApi = (): Promise<HttpResultData<any[]>> => request(`/data-banner/classify`)


/**
 * 获取广告信息
 * @returns {*}
 */
export const getBannerListApi = (where: any): Promise<HttpResultPaging<any[]>> => request(`/data-banner/list`, where)


/**
 * 创建广告
 * @type {string}
 */
export const createdBannerApi: string = `/data-banner/created`


/**
 * 创建广告
 * @type {string}
 */
export const updatedBannerApi: string = `/data-banner/updated`


/**
 * 修改轮播状态
 * @param id
 * @param status
 * @returns {*}
 */
export const changeStatusApi = (id: number, status: 0 | 1): Promise<HttpResult> => request(`/data-banner/status`, {id, status}, 'POST')


/**
 * 删除广告
 * @param id
 */
export const deleteBannerApi = (id: number): Promise<HttpResult> => request(`/data-banner/delete`, {id}, 'POST')

